<div class="modal fade " id="updateReportDataMaintainModal"  role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">数据维护</h3>
            </div>

            <form class="form-horizontal" role="form" id="updateReportDataMaintainForm"  method="post" action="/reportdatamaintain/" enctype="multipart/form-data">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="idLabel">序号</label>
                        <div class="col-sm-4">
                            <input id="id" name="id" type="text" disabled="disabled" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="fundIdLabel">账套号</label>
                        <div class="col-sm-4">
                            <input id="fundId" name="fundId" type="text" class="form-control"
                                   onkeyup= "if( /[^\d]/g.test(this.value)){alert('只能整数');this.value='';}">
                        </div>
                        <label class="col-sm-2 control-label" for="fundCodeLabel">基金代码</label>
                        <div class="col-sm-4">
                            <input id="fundCode" name="fundCode" type="text" class="form-control" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="fundNameLabel">基金名称</label>
                        <div class="col-sm-4">
                            <input id="fundName" name="fundName" type="text" class="form-control">
                        </div>
                        <label class="col-sm-2 control-label" for="managerLabel">产品管理人</label>
                        <div class="col-sm-4">
                            <input id="manager" name="manager" type="text" class="form-control"
                                   onkeyup= "if( /[^\d]/g.test(this.value)){alert('只能整数');this.value='';}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="productTypeLabel">产品类型</label>
                        <div class="col-sm-4">
                            <input id="productType" name="productType" type="text" class="form-control"
                                   onkeyup= "if( /[^\d]/g.test(this.value)){alert('只能整数');this.value='';}">
                        </div>
                        <label class="col-sm-2 control-label" for="checkDateLabel">核准时间</label>
                        <div class="col-sm-4">
                            <input id="checkDate" class="form-control" placeholder="YYYY-MM-DD" onClick="WdatePicker()">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="createDateLabel">成立时间</label>
                        <div class="col-sm-4">
                            <input id="createDate" class="form-control" placeholder="YYYY-MM-DD" onClick="WdatePicker()">
                        </div>
                        <label class="col-sm-2 control-label" for="issueAmountLabel">初始规模</label>
                        <div class="col-sm-4">
                            <input id="issueAmount" name="issueAmount" type="text" class="form-control"
                                   onkeyup= "if( /[^\d]/g.test(this.value)){alert('只能整数');this.value='';}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="openTypeLabel">开放类型</label>
                        <div class="col-sm-4">
                            <input id="openType" name="openType" type="text" class="form-control"
                                   onkeyup= "if( /[^\d]/g.test(this.value)){alert('只能整数');this.value='';}">
                        </div>
                        <label class="col-sm-2 control-label" for="openTermLabel">开放周期</label>
                        <div class="col-sm-4">
                            <input id="openTerm" name="openType" type="text" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for=isNonStandardLabel">是否非标</label>
                        <div class="col-sm-4">
                            <select id="isNonStandard" name="isNonStandard" class="form-control">
                                <option value="是" selected="selected">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                        <label class="col-sm-2 control-label" for=tempCodeLabel">临时编码</label>
                        <div class="col-sm-4">
                            <input id="tempCode" name="tempCode" type="text" class="form-control"
                                   onkeyup= "if( /[^\d]/g.test(this.value)){alert('只能整数');this.value='';}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="investmentSurveyLabel">标的概况</label>
                        <div class="col-sm-10">
                            <input id="investmentSurvey" name="investmentSurvey" type="text" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="box-footer">
                    <button type="button" class="btn btn-danger pull-left" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary pull-right" onclick="saveMaintainData()">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="dist/js/datepicker/WdatePicker.js" language="javascript" type="text/javascript" ></script>
<#include "../public/js.ftl" >
<#include "../public/css.ftl">
<script>
    function updateReportDataMaintainInit() {
        $("#id").val("");
        $("#fundId").val("");
        $("#fundCode").val("");
        $("#fundName").val("");
        $("#manager").val("");
        $("#productType").val("");
        $("#checkDate").val("");
        $("#createDate").val("");
        $("#issueAmount").val("");
        $("#isNonStandard").val("");
        $("#openType").val("");
        $("#openTerm").val("");
        $("#tempCode").val("");
        $("#investmentSurvey").val("");
    }

    function modifyReportDataMaintainInit(data){
        $("#id").val(data.id);
        $("#fundId").val(data.fundId);
        $("#fundCode").val(data.fundCode);
        $("#fundName").val(data.fundName);
        $("#manager").val(data.manager);
        $("#productType").val(data.productType);

        $("#checkDate").val(data.checkDate);
        $("#createDate").val(data.createDate);
        $("#issueAmount").val(data.issueAmount);
        $("#isNonStandard").val(data.isNonStandard);
        $("#openType").val(data.openType);
        $("#openTerm").val(data.openTerm);
        $("#tempCode").val(data.tempCode);
        $("#investmentSurvey").val(data.investmentSurvey);
    }

    function saveMaintainData(){
       //任务序号
        var id = $("#id").val();
        //账套号
        var fundId = $("#fundId").val();
        if(fundId.trim() == ""){
            toastr['error']("请输入账套号", '提示');
            return;
        }
        //基金代码
        var fundCode = $("#fundCode").val();
        if(fundCode.trim() == ""){
            toastr['error']("请输入基金代码", '提示');
            return;
        }
        //基金名称
        var fundName = $("#fundName").val();
        if(fundName.trim() == ""){
            toastr['error']("请输入基金名称", '提示');
            return;
        }
        //产品管理人
        var manager = $("#manager").val();
        if(manager.trim() == ""){
            toastr['error']("请输入产品管理人", '提示');
            return;
        }
        //组合类资管产品类型
        var productType = $("#productType").val();
        if(productType.trim() == ""){
            toastr['error']("请输入组合类资管产品类型", '提示');
            return;
        }
        //核准时间
        var checkDate = $("#checkDate").val();
        if(checkDate.trim() == ""){
            toastr['error']("请设置核准时间", '提示');
            return;
        }
        //成立时间
        var createDate = $("#createDate").val();
        if(createDate.trim() == ""){
            toastr['error']("请设置成立时间", '提示');
            return;
        }
        //初始规模
        var issueAmount = $("#issueAmount").val();
        if(issueAmount.trim() == ""){
            toastr['error']("请输入初始规模", '提示');
            return;
        }
        //开放/封闭类型
        var openType = $("#openType").val();
        if(openType.trim() == ""){
            toastr['error']("请输入开放/封闭类型", '提示');
            return;
        }
        //开放周期
        var openTerm = $("#openTerm").val();
        if(openTerm.trim() == ""){
            toastr['error']("请输入开放周期", '提示');
            return;
        }
        //是否非标
        var isNonStandard = $("#isNonStandard").val();
        if(isNonStandard.trim() == ""){
            toastr['error']("请输入是否非标", '提示');
            return;
        }
        //产品临时编码
        var tempCode = $("#tempCode").val();
        if(tempCode.trim() == ""){
            toastr['error']("请输入产品临时编码", '提示');
            return;
        }
        //投资标的概况
        var investmentSurvey = $("#investmentSurvey").val();

        var data = {
            id : id,
            fundId : fundId,
            fundCode : fundCode,
            fundName : fundName,
            manager : manager,
            productType : productType,
            checkDate : checkDate,
            createDate : createDate,
            issueAmount : issueAmount,
            openType : openType,
            openTerm : openTerm,
            isNonStandard : isNonStandard,
            tempCode : tempCode,
            investmentSurvey : investmentSurvey
        };

        var url = "/reportdatamaintain/maintain";
        postReq(url, data, function (result) {
            if (result.success) {
                updateReportDataMaintainInit();
                $("#dataTable").bootstrapTable("refresh");
                $("#updateReportDataMaintainModal").modal("hide");
                toastr['success']('数据保存成功', '提示');
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>
